LOCAL_PATH		:= $(call my-dir)

include $(CLEAR_VARS)

FEATURE_NEON:=

#if armeabi-v7a
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
	# add neon optimization code (only armeabi-v7a)
	FEATURE_NEON:=yes
else

endif


include $(CLEAR_VARS)
LOCAL_MODULE := nmath-prebuilt
LOCAL_SRC_FILES := physic-build/$(TARGET_ARCH_ABI)/libnmath.so
#LOCAL_EXPORT_C_INCLUDES := physic-build/$(TARGET_ARCH_ABI)/include
LOCAL_EXPORT_C_INCLUDES := physic-build/$(TARGET_ARCH_ABI)/nmath
LOCAL_EXPORT_LDLIBS := physic-build/$(TARGET_ARCH_ABI)/libnmath.so
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)

ifdef FEATURE_NEON
	include $(CLEAR_VARS)
	LOCAL_MODULE := nmath-prebuilt-neon
	LOCAL_SRC_FILES := physic-build/$(TARGET_ARCH_ABI)-neon/libnmath-neon.so
	LOCAL_EXPORT_C_INCLUDES := physic-build/$(TARGET_ARCH_ABI)-neon/include
	LOCAL_EXPORT_LDLIBS := physic-build/$(TARGET_ARCH_ABI)-neon/libnmath-neon.so
	LOCAL_PRELINK_MODULE := true
	include $(PREBUILT_SHARED_LIBRARY)
endif

include $(CLEAR_VAR)

ifdef FEATURE_NEON
	#Be careful with this flag
	LOCAL_ALLOW_UNDEFINED_SYMBOLS := false
	LOCAL_MODULE	:= physiclab-neon
	LOCAL_MODULE_FILENAME := physiclab-neon
	LOCAL_CFLAGS    := -Werror #-Wall -Wextra
	LOCAL_SRC_FILES := physic-jni.c physic.c matrix.c
#	LOCAL_SHARED_LIBRARIES := -lpthread $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)/libnmath-neon.so
	LOCAL_SHARED_LIBRARIES := nmath-prebuilt-neon 
#	LOCAL_LDLIBS    := -lm -llog -lGLESv2 $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)-neon/libnmath-neon.so
	LOCAL_LDLIBS    := -lm -llog $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)-neon/libnmath-neon.so
	include $(BUILD_SHARED_LIBRARY)
endif

#Be careful with this flag
LOCAL_ALLOW_UNDEFINED_SYMBOLS := false
LOCAL_MODULE	:= physiclab
LOCAL_MODULE_FILENAME := physiclab
LOCAL_CFLAGS    := -Werror #-Wall -Wextra
LOCAL_SRC_FILES := physic-jni.c physic.c matrix.c
#LOCAL_SHARED_LIBRARIES := -lpthread $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)/libnmath.so
LOCAL_SHARED_LIBRARIES := nmath-prebuilt
#LOCAL_LDLIBS    := -lm -llog -lGLESv2 $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)/libnmath.so
LOCAL_LDLIBS    := -lm -llog $(LOCAL_PATH)/physic-build/$(TARGET_ARCH_ABI)/libnmath.so
include $(BUILD_SHARED_LIBRARY)
$(call import-module, cpufeatures)